<?php
class Project_Model extends CI_Model{
	function __construct(){
		parent::__construct();
	}
	function insert_project($ID,$Name,$Type,$ReqWord,$GenDesign, $DtlDesign,$Coding,$Testing,$Finish)
	{
		$data = array(
					'ID'=>$ID,
					'Name'=>$Name,
					'type'=>$Type,
					'ReqWord'=>$ReqWord,
					'GenDesign'=>$GenDesign,
					'DtlDesign'=>$DtlDesign,
					'Coding'=>$Coding,
					'Testing'=>$Testing,
					'Finish'=>$Finish
					);
			
			$this->db->insert('project',$data);
	}
	function update_project($ID,$Name,$Type,$ReqWord,$GenDesign, $DtlDesign,$Coding,$Testing,$Finish)
		{
			$data = array(
					'ID'=>$ID,
					'Name'=>$Name,
					'type'=>$Type,
					'ReqWord'=>$ReqWord,
					'GenDesign'=>$GenDesign,
					'DtlDesign'=>$DtlDesign,
					'Coding'=>$Coding,
					'Testing'=>$Testing,
					'Finish'=>$Finish
					);
			$this->db->where('ID',$ID);
			$this->db->update('project',$data);
		}
	function delete_word($ID,$delete_id)
	{
		$this->db->where("ID", $ID);
		
		$this->db->delete('project');
	} 
	
	
	//这个方法有待考证。一般view只是由多个表拼接起来的，不便修改
	function insert_View_pmember($ID,$PID,$Name,$UAccount)
	{
		$data=array(
				'ID'=>$ID,
				'PID'=>$PID,
				'Name'=>$Name,
				'UAccount'=>$UAccount
				);
		$this->db->where('ID',$ID);
		$this->db->insert('View_pmember',$data);
	}

	function query_project()
	{
		$query = $this->db->get_where('project');
		return $query->result_array();
	}
	
	
	function query_all_project_name()
	{
		$query = $this->db->get_where('project');
		foreach($query->result() as $row)
		{
			$data['name'][]=$row->Name;
			$data['ID'][]=$row->ID;
		}
		return $data;
	}
	
	function query_member_id($pid)
	{
		$query=$this->db->get_where('view_pmember',array('PID'=>$pid));
		return $query->result_array();
	}
	
	
	function insert_project_member($pid,$account)
	{
		$data = array(
				'PID'=>$pid,
				'UAccount'=>$account);
		$this->db->insert('pmember',$data);
		return true;
	}
	

	function query_project_user_account($account)
	{
		$query = $this->db->get_where('view_pmember',array('UAccount'=>$account));
		return  $query->result_array();
	}
	
	
	
	
}
	